// FreeZzaph.cs
// 
// Copyright © 2009 FreeZzaph
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.
//

using System;
using System.Collections.Generic;

namespace LibFreeZzaph
{	
	
	/// <summary>
	/// Main FreeZzaph Library class. Used by applications that utilize the
	/// FreeZzaph Library to access the library's functionality. Plug-in
	/// developers do not need to worry about this class; they should look at
	/// the IFreeZzaphPlugin interface and derivatives.
	/// </summary>
	public sealed class FreeZzaph
	{
		/* This class is essentially an adapter to the PluginManager.
		 * This has been done in order to be able to keep the PluginManager
		 * and internal class, so that plug-in developers cannot (easily) make
		 * use of the real PluginManager class.
		 */
		
		private PluginManager pm = new PluginManager();
		
		/// <value>
		/// Gets the loaded Content Provider plug-ins
		/// </value>
		public IDictionary<string, IFreeZzaphContentProviderPlugin> ContentProviderPlugins
		{
			get
			{
				return pm.ContentProviderPlugins;
			}
		}
		
		/// <value>
		/// Gets the loaded Post-Processor plug-ins
		/// </value>
		public IDictionary<string, IFreeZzaphPostProcessorPlugin> PostProcessorPlugins
		{
			get
			{
				return pm.PostProcessorPlugins;
			}
		}
		
		/// <summary>
		/// Loads plug-ins in the given directory. This method can be called
		/// several times to load plug-ins from different directories.
		/// </summary>
		/// <param name="pluginDirectory">
		/// The directory from which to load plug-ins.
		/// </param>
		public void LoadPlugins(string pluginDirectory)
		{
			pm.LoadPlugins(pluginDirectory);
		}
		
		/// <summary>
		/// Calls a plug-in registered command.
		/// </summary>
		/// <param name="type">
		/// The plug-in's Type. Must be the Type of an object that implements the
		/// IFreeZzaphContentProviderPlugin interface.
		/// </param>
		/// <param name="command">
		/// The command to issue.
		/// </param>
		/// <param name="parameters">
		/// A list of parameters provided to the plug-in command.
		/// </param>
		/// <returns>
		/// True if the command was handled, false otherwise.
		/// </returns>
		public bool IssuePluginCommand(Type type, string command, IList<string> parameters)
		{
			return pm.HandleCommand(type, command, parameters);
		}
	}
}
